# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: tobias <tobias@arhlinux.org>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - upstream fixes for FTBFS on ARM

pkgname=exiv2
pkgver=0.27.3
pkgrel=1
pkgdesc="Exif, Iptc and XMP metadata manipulation library and tools"
url="https://exiv2.org"
arch=('x86_64')
license=('GPL2')
depends=('gcc-libs' 'zlib' 'expat' 'gettext' 'curl')
makedepends=('cmake' 'gtest')
checkdepends=('python')
provides=('libexiv2.so')
source=(https://github.com/Exiv2/exiv2/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz
        arm.patch)
sha512sums=('92775e1c79f06f7b4fb4c214cb2732982cbf01d8bc07d0e8f440facca712a41e579ef2baf72a0471889bb74d3f4975fbc76b47adbe6839decb6770458f76a341'
            '40ceab3f4d27d0fae1f5700b0b880ebdbeccf2da992cdc956e20a39b1c03531e6d03a9aa99f7842d3bfd44763a7f7c1d2b2eaa1a70cd1ead16144d7f73f49de1')
b2sums=('f57afed9adbc578c6db0bec843112b12af4aa706a92a12fcd6cfe989ddc07090701f99bc3fb17946d696fe36073d8cefa4ec87a819e8407fda8c48f25d368964'
        '6904c03d600fd6ffc9a84b96ab5d216ab0c07b6cd8e1a82384809e21ab4cf0f8314363dbe7b58616b6b6459b3e6c63f662a08a9eca7a57a27af2213a049ccb42')

prepare() {
  cd ${pkgname}-${pkgver}
  patch -p1 -i ../arm.patch
}

build() {
  cd ${pkgname}-${pkgver}
  cmake -B build \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_SKIP_RPATH=ON \
    -DEXIV2_BUILD_SAMPLES=ON \
    -DEXIV2_BUILD_UNIT_TESTS=ON \
    -DEXIV2_ENABLE_VIDEO=ON \
    -DEXIV2_ENABLE_NLS=ON \
    -DEXIV2_ENABLE_XMP=ON \
    -DEXIV2_ENABLE_CURL=ON \
    -DEXIV2_ENABLE_WEBREADY=ON
  make -C build VERBOSE=1
}

check() {
  cd ${pkgname}-${pkgver}
  make -C build tests
}

package() {
  cd ${pkgname}-${pkgver}
  # remove samples instal which are only needed for unit tests
  sed '/samples\/cmake_install.cmake/d' -i build/cmake_install.cmake
  make -C build DESTDIR="${pkgdir}" install
}

# vim: ts=2 sw=2 et:
